$(function () {
    var date = new Date();
    var currentMonth = date.getMonth() + 1;
    if (currentMonth < 10) currentMonth = "0" + currentMonth;
    $("#revisitTime").val(date.getFullYear() + "-" + currentMonth + "-" + date.getDate());
});
var currDT;
var date = new Date();
var currentYear = date.getFullYear();       // 当前年份
var currentMonth = date.getMonth() + 1;    // 当前月份
var currentDay = date.getDate();         // 今日日期 几号
if (currentMonth < 10) currentMonth = "0" + currentMonth;
if (currentDay < 10) currentDay = "0" + currentDay;
var nowTime = currentYear + "-" + currentMonth + "-" + currentDay;
$("#submission1").click(function () {
    var createName = $("#tcValue", parent.document).val();  //创建人
    var followStatus = $("#followStatus", parent.document).val();   //tc
    var consumptionStatus = $("#consumptionStatus", parent.document).val();  //创建人
    var revisit = $("#revisit", parent.document).val();  //回访人员
    var remarks = $("#remarks", parent.document).val();   //回访内容
    var revisitContent = $("#revisitContent", parent.document).val();   //回访结果
    var reservationsId = $("#reservationsId", parent.document).val();   //预约id
    var customerId = $("#customerId", parent.document).val();   //客户id
    var arrivalStore = $("#arrivalStore", parent.document).val();   //门诊
    var revisitTime = $("#revisitTime").val();   //回访时间
    if (revisitTime.substring(0, 10) < nowTime && (followStatus == "" || followStatus == null || followStatus == "跟踪中")) {
        alert("下次跟进时间要不小于今天！");
        return;
    } else {
        var r = confirm("确定要再回访？");
        if (r == true) {
            $.ajax({
                url: Feng.ctxPath + "/tcRevisit/addTcContentz",
                type: "post",
                data: {
                    revisitTime: revisitTime,
                    createName: createName,
                    remarks: remarks,
                    arrivalStore: arrivalStore,
                    followStatus: followStatus,
                    consumptionStatus: consumptionStatus,
                    revisitContent: revisitContent,
                    customerId: customerId,
                    reservationsId: reservationsId,
                    revisit: revisit
                },
                success: function (data) {
                    Feng.success('操作成功!');
                    $("#revisitTime", parent.document).val(revisitTime);
                    window.parent.parent.TcFollowTableList.table.refresh();
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                },
                error: function (data) {
                    alert('没有权限，请联系管理员!');
                }
            });
        }
    }
});
function checkDate() {
    var stime = document.getElementById("revisitTime").innerHTML;
    if (stime == "" || stime == null) {
        currDT = new Date();
    } else {
        currDT = new Date(stime);
    }
}
$(".btn1").click(function () {
    var date = new Date();
    var dateno=date.getDate();
    date.setMonth(date.getMonth() + 3, 1);
    $("#revisitTime").val(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + dateno);
});
$(".btn2").click(function () {
    var date = new Date();
    var dateno=date.getDate();
    date.setMonth(date.getMonth() + 6, 1);
    $("#revisitTime").val(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + dateno);
});
$(".btn3").click(function () {
    var date = new Date();
    var dateno=date.getDate();
    date.setFullYear(date.getFullYear() + 1);
    $("#revisitTime").val(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + dateno);
});